#include "FileDataSource.h"
#include "FileDataTarget.h"
#include "HuffmanArchiver.h"
#include "HuffmanOptions.h"
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>

size_t fileSize(char const* filename)
{
	struct stat st;
	stat(filename, &st);
	return st.st_size;
}

void code()
{
	assert(fileSize("input") <= MAX_FILE_LEN);
	FileDataSource* ds = new FileDataSource("input");
	FileDataTarget* dt = new FileDataTarget("output");
	HuffmanArchiver* arch = new HuffmanArchiver();

	arch->archive(ds, dt);
}

void uncode()
{
	FileDataSource* ds = new FileDataSource("output");
	FileDataTarget* dt = new FileDataTarget("output23");
	HuffmanArchiver* arch = new HuffmanArchiver();
	arch->unarchive(ds, dt);
}

int main()
{	
	code();
	//uncode();
	system("pause");
	return 0;
}